package org.enwey.icarenew.Adapter;

import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import org.enwey.icarenew.Activity.Login.LoginActivity;
import org.enwey.icarenew.Component.UserNewItem;
import org.enwey.icarenew.Model.Topic;
import org.enwey.icarenew.Model.UserNew;

import java.util.List;

/**
 * Created by John on 1/26/2015.
 */
public class UserNewAdapter extends BaseAdapter {
    private static final String TAG = "UserNewAdapter";
    private Context context;
    private List<Topic> userNewList;

    public UserNewAdapter(Context context) {
        this.context = context;
    }

    public void setUserNewList(List<Topic> list) {
        this.userNewList = list;
    }

    @Override
    public int getCount() {
        return userNewList != null ? userNewList.size() : 0;
    }

    @Override
    public Object getItem(int position) {
        return userNewList != null ? userNewList.size() : null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Log.v(TAG,position+"");
        UserNewItem userNewItem = null;
        if (convertView == null) {
            userNewItem = new UserNewItem(context);
        } else {
            userNewItem = (UserNewItem) convertView;
        }
        userNewItem.setUserNew(userNewList.get(position));

        return userNewItem;
    }
}
